import _ from 'lodash'

const MATERIAL = {
  MATERIAL_DATA: 'MATERIAL_DATA'
}

const initialState = {
  materialData: {
    form: {
      name: '',
      brandId: '',
      country: '100000',
      materialModel: '',
      attribute: 1,
      styles: [],
      category: '',
      supplyCycle: '',
      serviceTime: '',
      isOnSales: '',
      items: [],
      table: {},
      attr: [],
      fixParams: [],
      descriptions: [],
      fileGridMapping: [],
      materialDetail: [],
      // materialTextureSu: [],
      materialModelFile: [],
      type: 1,
      code: '',
      spec: {
        items: [],
        prices: {
          header: [],
          body: []
        }
      }
    },
    currentValue: '',
    category: {
      stair: [],
      stair_id: '',
      stair_keyword: '',
      second: [],
      second_id: '',
      second_keyword: '',
      three: [],
      three_id: '',
      three_keyword: '',
      four: [],
      four_id: '',
      four_keyword: '',
    },
  }
}

const mutations = {
  [MATERIAL.MATERIAL_DATA] (state, payload) {
    state.materialData = {
      ...state.materialData,
      ...payload
    }
  },
}

const actions = {
  changeMaterialData ({ commit }, payload) {
    commit(MATERIAL.MATERIAL_DATA, payload)
  }
}

const getters = {}

export default {
  state: _.cloneDeep(initialState),
  mutations,
  actions,
  getters
}
